// 用 TS 类实现一个简单的 TODO 列表（包含添加、删除、标记完成等功能），并应用访问修饰符、方法重载等特性！
class TodoItem {
    private static idCounter = 0;
    public id: number;
    public title: string;
    public completed: boolean;

    constructor(title: string) {
        this.id = TodoItem.idCounter++;
        this.title = title;
        this.completed = false;
    }

    toggleCompletion(): void {
        this.completed = !this.completed;
    }
}
class TodoList {
    private items: TodoItem[] = [];

    addItem(title: string): void {
        const newItem = new TodoItem(title);
        this.items.push(newItem);
    }

    removeItem(id: number): void {
        this.items = this.items.filter(item => item.id !== id);
    }

    toggleItemCompletion(id: number): void {
        const item = this.items.find(item => item.id === id);
        if (item) {
            item.toggleCompletion();
        }
    }

    getItems(): TodoItem[] {
        return this.items;
    }
}